<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Compress::Bzip2 - Interface to Bzip2 compression library - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Compress-Bzip2 - MetaCPAN" href="https://metacpan.org/dist/Compress-Bzip2/releases.rss" />
        <link rel="canonical" href="./Compress::Bzip2.html" />
        <meta name="description" content="Interface to Bzip2 compression library" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Compress::Bzip2" />
<meta name="twitter:title"       content="Compress::Bzip2" />
<meta name="twitter:description" content="Interface to Bzip2 compression library" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Compress::Bzip2.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Compress-Bzip2 was released.">
      <span class="relatize">18 Jul 2020 06:12:25 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Compress-Bzip2">Compress-Bzip2</a>
  </li>
  <li>
    Module version: 2.28
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Compress-Bzip2/source/lib/Compress/Bzip2.pm">Source</a>
    (<a href="https://metacpan.org/dist/Compress-Bzip2/source/lib/Compress/Bzip2.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Compress-Bzip2/source/lib/Compress">Browse</a>
    (<a href="https://metacpan.org/dist/Compress-Bzip2/source/lib/Compress?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Compress-Bzip2/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Compress-Bzip2/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/rurban/Compress-Bzip2">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Compress-Bzip2">Issues</a>
      (3)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Compress-Bzip2+2.28" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/C/Compress-Bzip2.html?oncpan=1&amp;distmat=1&amp;version=2.28&amp;grade=2" style="color: #090">2542</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/C/Compress-Bzip2.html?oncpan=1&amp;distmat=1&amp;version=2.28&amp;grade=3" style="color: #900">7</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/C/Compress-Bzip2.html?oncpan=1&amp;distmat=1&amp;version=2.28&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/RURBAN/Compress-Bzip2-2.28">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Compress-Bzip2 who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Compress-Bzip2-2.28/index.html">% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Compress-Bzip2/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/R/RU/RURBAN/Compress-Bzip2-2.28.tar.gz">
      Download (<span itemprop="fileSize">874.65KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FRURBAN%2FCompress-Bzip2-2.28%2Flib%2FCompress%2FBzip2.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Compress-Bzip2/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Compress-Bzip2/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Compress-Bzip2">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Compress-Bzip2">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Compress/Bzip2.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="RURBAN/Compress-Bzip2-2.28"
>2.28
  (RURBAN on 2020-07-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.27"
>2.27
  (RURBAN on 2020-05-26)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.26"
>2.26
  (RURBAN on 2017-04-10)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.25"
>2.25
  (RURBAN on 2016-11-11)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.24"
>2.24
  (RURBAN on 2015-12-08)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.22"
>2.22
  (RURBAN on 2015-02-19)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.20"
>2.20
  (RURBAN on 2015-01-15)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.19"
>2.19
  (RURBAN on 2014-10-24)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.18"
>2.18
  (RURBAN on 2014-08-06)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.17"
>2.17
  (RURBAN on 2013-08-28)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.10"
>2.10
  (RURBAN on 2013-03-26)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.09"
>2.09
  (ARJAY on 2005-08-09)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.08"
>2.08
  (ARJAY on 2005-05-12)</option>
<option
  
  value="DBROBINS/Compress-Bzip2-1.03"
>1.03
  (DBROBINS on 2005-01-12)</option>
<option
  
  value="KCARNUT/Compress-Bzip2-1.02"
>1.02
  (KCARNUT on 2003-06-16)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.10"
>1.10
  (ZOOVY on 2002-12-24)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.01"
>1.01
  (ZOOVY on 2001-06-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="RURBAN/Compress-Bzip2-2.16"
>2.16
  (RURBAN on 2013-06-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.15"
>2.15
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.14"
>2.14
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.13"
>2.13
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.12"
>2.12
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.11"
>2.11
  (RURBAN on 2013-04-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.07"
>2.07
  (ARJAY on 2005-05-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.06"
>2.06
  (ARJAY on 2005-04-30)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.05"
>2.05
  (ARJAY on 2005-04-27)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.04"
>2.04
  (ARJAY on 2005-04-25)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.03"
>2.03
  (ARJAY on 2005-04-24)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.02"
>2.02
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.01"
>2.01
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.00"
>2.00
  (ARJAY on 2005-04-20)</option>
<option
  
  value="AZEMGI/Compress-Bzip2-1.00"
>1.00
  (AZEMGI on 1999-03-07)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/RURBAN/Compress-Bzip2-2.28/diff/' + encodeURIComponent(this.value) + '/lib/Compress/Bzip2.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="RURBAN/Compress-Bzip2-2.28"
>2.28
  (RURBAN on 2020-07-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.27"
>2.27
  (RURBAN on 2020-05-26)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.26"
>2.26
  (RURBAN on 2017-04-10)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.25"
>2.25
  (RURBAN on 2016-11-11)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.24"
>2.24
  (RURBAN on 2015-12-08)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.22"
>2.22
  (RURBAN on 2015-02-19)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.20"
>2.20
  (RURBAN on 2015-01-15)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.19"
>2.19
  (RURBAN on 2014-10-24)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.18"
>2.18
  (RURBAN on 2014-08-06)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.17"
>2.17
  (RURBAN on 2013-08-28)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.10"
>2.10
  (RURBAN on 2013-03-26)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.09"
>2.09
  (ARJAY on 2005-08-09)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.08"
>2.08
  (ARJAY on 2005-05-12)</option>
<option
  
  value="DBROBINS/Compress-Bzip2-1.03"
>1.03
  (DBROBINS on 2005-01-12)</option>
<option
  
  value="KCARNUT/Compress-Bzip2-1.02"
>1.02
  (KCARNUT on 2003-06-16)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.10"
>1.10
  (ZOOVY on 2002-12-24)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.01"
>1.01
  (ZOOVY on 2001-06-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="RURBAN/Compress-Bzip2-2.16"
>2.16
  (RURBAN on 2013-06-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.15"
>2.15
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.14"
>2.14
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.13"
>2.13
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.12"
>2.12
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.11"
>2.11
  (RURBAN on 2013-04-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.07"
>2.07
  (ARJAY on 2005-05-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.06"
>2.06
  (ARJAY on 2005-04-30)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.05"
>2.05
  (ARJAY on 2005-04-27)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.04"
>2.04
  (ARJAY on 2005-04-25)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.03"
>2.03
  (ARJAY on 2005-04-24)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.02"
>2.02
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.01"
>2.01
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.00"
>2.00
  (ARJAY on 2005-04-20)</option>
<option
  
  value="AZEMGI/Compress-Bzip2-1.00"
>1.00
  (AZEMGI on 1999-03-07)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Carp" title="Carp" class="ellipsis">Carp</a></li>
  <li><a href="https://metacpan.org/pod/Config" title="Config" class="ellipsis">Config</a></li>
  <li><a href="https://metacpan.org/pod/Fcntl" title="Fcntl" class="ellipsis">Fcntl</a></li>
  <li><a href="https://metacpan.org/pod/File::Copy" title="File::Copy" class="ellipsis">File::Copy</a></li>
  <li><a href="https://metacpan.org/pod/File::Spec" title="File::Spec" class="ellipsis">File::Spec</a></li>
  <li><a href="https://metacpan.org/pod/Getopt::Std" title="Getopt::Std" class="ellipsis">Getopt::Std</a></li>
  <li><a href="https://metacpan.org/pod/Test::More" title="Test::More" class="ellipsis">Test::More</a></li>
  <li><a href="https://metacpan.org/pod/constant" title="constant" class="ellipsis">constant</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Compress::Bzip2/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Compress%3A%3ABzip2">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Compress-Bzip2">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/RURBAN/Compress-Bzip2-2.28/view/lib/Compress/Bzip2.pm">This version</a>
    </li>
    <li>
      <a href="./Compress::Bzip2.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
    3 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 1 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
      data-cpan-author="ARJAY"
      data-contrib-email="arjay@cpan.org"
    >
      <a href="https://metacpan.org/author/ARJAY" class="cpan-author">
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/ce843cd388fa6a856f02f203a2340dbd?d=identicon&amp;s=20" />
      Rob Janes
      </a>
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/RURBAN" class="author-name">Reini Urban</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Compress/Bzip2.pm&#39;" class="">
<option
  selected
  value="RURBAN/Compress-Bzip2-2.28"
>2.28
  (RURBAN on 2020-07-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.27"
>2.27
  (RURBAN on 2020-05-26)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.26"
>2.26
  (RURBAN on 2017-04-10)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.25"
>2.25
  (RURBAN on 2016-11-11)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.24"
>2.24
  (RURBAN on 2015-12-08)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.22"
>2.22
  (RURBAN on 2015-02-19)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.20"
>2.20
  (RURBAN on 2015-01-15)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.19"
>2.19
  (RURBAN on 2014-10-24)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.18"
>2.18
  (RURBAN on 2014-08-06)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.17"
>2.17
  (RURBAN on 2013-08-28)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.10"
>2.10
  (RURBAN on 2013-03-26)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.09"
>2.09
  (ARJAY on 2005-08-09)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.08"
>2.08
  (ARJAY on 2005-05-12)</option>
<option
  
  value="DBROBINS/Compress-Bzip2-1.03"
>1.03
  (DBROBINS on 2005-01-12)</option>
<option
  
  value="KCARNUT/Compress-Bzip2-1.02"
>1.02
  (KCARNUT on 2003-06-16)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.10"
>1.10
  (ZOOVY on 2002-12-24)</option>
<option
  
  value="ZOOVY/Compress-Bzip2-1.01"
>1.01
  (ZOOVY on 2001-06-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="RURBAN/Compress-Bzip2-2.16"
>2.16
  (RURBAN on 2013-06-18)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.15"
>2.15
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.14"
>2.14
  (RURBAN on 2013-04-05)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.13"
>2.13
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.12"
>2.12
  (RURBAN on 2013-04-01)</option>
<option
  
  value="RURBAN/Compress-Bzip2-2.11"
>2.11
  (RURBAN on 2013-04-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.07"
>2.07
  (ARJAY on 2005-05-01)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.06"
>2.06
  (ARJAY on 2005-04-30)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.05"
>2.05
  (ARJAY on 2005-04-27)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.04"
>2.04
  (ARJAY on 2005-04-25)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.03"
>2.03
  (ARJAY on 2005-04-24)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.02"
>2.02
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.01"
>2.01
  (ARJAY on 2005-04-23)</option>
<option
  
  value="ARJAY/Compress-Bzip2-2.00"
>2.00
  (ARJAY on 2005-04-20)</option>
<option
  
  value="AZEMGI/Compress-Bzip2-1.00"
>1.00
  (AZEMGI on 1999-03-07)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Compress-Bzip2">Compress-Bzip2-2.28</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage three &#10;
          • 13 direct dependents &#10;          • 557 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Compress-Bzip2-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Compress-Bzip2-2.28">
    <input type="hidden" name="author" value="RURBAN">
    <input type="hidden" name="distribution" value="Compress-Bzip2">
    <button type="submit" class="favorite highlight"><span>3</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Compress::Bzip2.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>3</span> ++</a>
</div>
   / <span>Compress::Bzip2</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Compress::Bzip2.html#NAME">NAME</a></li>
  <li><a href="./Compress::Bzip2.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Compress::Bzip2.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./Compress::Bzip2.html#FILE-READ/WRITE-INTERFACE">FILE READ/WRITE INTERFACE</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#$bz-=-bzopen(filename-or-filehandle,-mode)">$bz = bzopen(filename or filehandle, mode)</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-=-Compress::Bzip2-%3Enew(-%5BPARAMS%5D-)">$bz = Compress::Bzip2-&gt;new( [PARAMS] )</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Ebzopen(filename-or-filehandle,-mode)">$bz-&gt;bzopen(filename or filehandle, mode)</a></li>
      <li><a href="./Compress::Bzip2.html#$bytesread-=-$bz-%3Ebzread($buffer-%5B,-$size%5D)-;">$bytesread = $bz-&gt;bzread($buffer [, $size]) ;</a></li>
      <li><a href="./Compress::Bzip2.html#$bytesread-=-$bz-%3Ebzreadline($line)-;">$bytesread = $bz-&gt;bzreadline($line) ;</a></li>
      <li><a href="./Compress::Bzip2.html#$byteswritten-=-$bz-%3Ebzwrite($buffer-%5B,-$limit%5D)-;">$byteswritten = $bz-&gt;bzwrite($buffer [, $limit]) ;</a></li>
      <li><a href="./Compress::Bzip2.html#$status-=-$bz-%3Ebzflush($flush)-;">$status = $bz-&gt;bzflush($flush) ;</a></li>
      <li><a href="./Compress::Bzip2.html#$status-=-$bz-%3Ebzeof()-;">$status = $bz-&gt;bzeof() ;</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Ebzclose">$bz-&gt;bzclose</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Ebzsetparams(-%5BPARAMS%5D-);">$bz-&gt;bzsetparams( [PARAMS] );</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Ebzerror">$bz-&gt;bzerror</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Ebzclearerr">$bz-&gt;bzclearerr</a></li>
      <li><a href="./Compress::Bzip2.html#$bzerrno">$bzerrno</a></li>
      <li><a href="./Compress::Bzip2.html#$bz-%3Eprefix">$bz-&gt;prefix</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#Compress::Bzip2-Utilities">Compress::Bzip2 Utilities</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#bzip2(-%5BOPTS%5D,-filename)">bzip2( [OPTS], filename)</a></li>
      <li><a href="./Compress::Bzip2.html#bunzip2(filename)">bunzip2(filename)</a></li>
      <li><a href="./Compress::Bzip2.html#bzcat(filenames...)">bzcat(filenames...)</a></li>
      <li><a href="./Compress::Bzip2.html#bzlibversion()">bzlibversion()</a></li>
      <li><a href="./Compress::Bzip2.html#bzinflateInit(-opts...-)">bzinflateInit( opts... )</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#Internal-Utilties">Internal Utilties</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#bz_seterror(errno,-msg)-=head2-$bz-%3Eis_read()-=head2-$bz-%3Eis_stream()-=head2-$bz-%3Eis_write()-=head2-$bz-%3Etotal_in()-=head2-$bz-%3Etotal_out()-=head2-version()">bz_seterror(errno, msg) =head2 $bz-&gt;is_read() =head2 $bz-&gt;is_stream() =head2 $bz-&gt;is_write() =head2 $bz-&gt;total_in() =head2 $bz-&gt;total_out() =head2 version()</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#Compress::Bzip2-1.03-COMPATIBILITY">Compress::Bzip2 1.03 COMPATIBILITY</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#$dest-=-compress(-$string,-%5B$level%5D-)">$dest = compress( $string, [$level] )</a></li>
      <li><a href="./Compress::Bzip2.html#$dest-=-decompress($string,-%5B$level%5D)">$dest = decompress($string, [$level])</a></li>
      <li><a href="./Compress::Bzip2.html#uncompress($string,-%5B$level%5D)">uncompress($string, [$level])</a></li>
      <li><a href="./Compress::Bzip2.html#$stream-=-compress_init(-%5BPARAMS%5D-)">$stream = compress_init( [PARAMS] )</a></li>
      <li><a href="./Compress::Bzip2.html#$stream-=-decompress_init(-%5BPARAMS%5D-)">$stream = decompress_init( [PARAMS] )</a></li>
      <li><a href="./Compress::Bzip2.html#$output-=-$stream-%3Eadd(-$string-)">$output = $stream-&gt;add( $string )</a></li>
      <li><a href="./Compress::Bzip2.html#$output-=-$stream-%3Efinish(-%5B$string%5D-)">$output = $stream-&gt;finish( [$string] )</a></li>
      <li><a href="./Compress::Bzip2.html#$stream-%3Eerror">$stream-&gt;error</a></li>
      <li><a href="./Compress::Bzip2.html#$stream-%3Einput_size">$stream-&gt;input_size</a></li>
      <li><a href="./Compress::Bzip2.html#$stream-%3Eoutput_size">$stream-&gt;output_size</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#GZIP-COMPATIBILITY-INTERFACE">GZIP COMPATIBILITY INTERFACE</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#$gz-=-gzopen(-$filename,-$mode-)"> $gz = gzopen( $filename, $mode ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzread(-$buffer,-%5B-$length-%5D-)"> $gz-&gt;gzread( $buffer, [ $length ] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzreadline(-$buffer-)"> $gz-&gt;gzreadline( $buffer ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzwrite(-$buffer-)"> $gz-&gt;gzwrite( $buffer ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzflush(-%5B$flushtype%5D-)"> $gz-&gt;gzflush( [$flushtype] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzclose(-)"> $gz-&gt;gzclose( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzeof(-)"> $gz-&gt;gzeof( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzerror(-)"> $gz-&gt;gzerror( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$gz-%3Egzsetparams(-$level,-$strategy-)"> $gz-&gt;gzsetparams( $level, $strategy ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-=-deflateInit(-%5BOPTS%5D-)"> $d = deflateInit( [OPTS] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Edeflate(-$buffer-)"> $d-&gt;deflate( $buffer ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3EdeflateParams(-%5BOPTS%5D-)"> $d-&gt;deflateParams( [OPTS] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Eflush(-%5B$flushtype%5D-)"> $d-&gt;flush( [$flushtype] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Edict_adler(-)"> $d-&gt;dict_adler( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Emsg(-)"> $d-&gt;msg( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-=-inflateInit(-%5BOPTS%5D-)"> $d = inflateInit( [OPTS] ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Einflate(-)"> $d-&gt;inflate( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3EinflateSync(-)"> $d-&gt;inflateSync( ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Eadler32(-$crc-)"> $d-&gt;adler32( $crc ) </a></li>
      <li><a href="./Compress::Bzip2.html#$d-%3Ecrc32(-$crc-)"> $d-&gt;crc32( $crc ) </a></li>
      <li><a href="./Compress::Bzip2.html#$buffer-=-memGzip(-$buffer-)"> $buffer = memGzip( $buffer ) </a></li>
      <li><a href="./Compress::Bzip2.html#$buffer-=-memGunzip(-$buffer-)"> $buffer = memGunzip( $buffer ) </a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#IN-MEMORY-COMPRESS/UNCOMPRESS">IN-MEMORY COMPRESS/UNCOMPRESS</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#$compressed-=-memBzip($buffer);">$compressed = memBzip($buffer);</a></li>
      <li><a href="./Compress::Bzip2.html#$uncompressed-=-memBunzip($buffer);">$uncompressed = memBunzip($buffer);</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#STREAM-DEFLATE-(=-COMPRESS)">STREAM DEFLATE (= COMPRESS)</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#($d,-$status)-=-bzdeflateInit(-%5BPARAMS%5D-)">($d, $status) = bzdeflateInit( [PARAMS] )</a></li>
      <li><a href="./Compress::Bzip2.html#($out,-$status)-=-$d-%3Ebzdeflate($buffer)">($out, $status) = $d-&gt;bzdeflate($buffer)</a></li>
      <li><a href="./Compress::Bzip2.html#($out,-$status)-=-$d-%3Ebzflush(%5Bflush_type%5D)">($out, $status) = $d-&gt;bzflush([flush_type])</a></li>
      <li><a href="./Compress::Bzip2.html#Example">Example</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#STREAM-INFLATE">STREAM INFLATE</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#($i,-$status)-=-inflateInit()">($i, $status) = inflateInit()</a></li>
      <li><a href="./Compress::Bzip2.html#($out,-$status)-=-$i-%3Ebzinflate($buffer)">($out, $status) = $i-&gt;bzinflate($buffer)</a></li>
      <li><a href="./Compress::Bzip2.html#Example1">Example</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#EXAMPLES">EXAMPLES</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#A-bzcat-function">A bzcat function</a></li>
      <li><a href="./Compress::Bzip2.html#A-grep-using-bzreadline">A grep using bzreadline</a></li>
      <li><a href="./Compress::Bzip2.html#Streaming-Compression">Streaming Compression</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#EXPORT">EXPORT</a>
    <ul>
      <li><a href="./Compress::Bzip2.html#Export-tag-:all">Export tag :all</a></li>
      <li><a href="./Compress::Bzip2.html#Export-tag-:constants">Export tag :constants</a></li>
      <li><a href="./Compress::Bzip2.html#Export-tag-:bzip1">Export tag :bzip1</a></li>
      <li><a href="./Compress::Bzip2.html#Export-tag-:utilities">Export tag :utilities</a></li>
      <li><a href="./Compress::Bzip2.html#Export-tag-:gzip">Export tag :gzip</a></li>
    </ul>
  </li>
  <li><a href="./Compress::Bzip2.html#Exportable-constants">Exportable constants</a></li>
  <li><a href="./Compress::Bzip2.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Compress::Bzip2.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./Compress::Bzip2.html#COPYRIGHT-AND-LICENSE">COPYRIGHT AND LICENSE</a></li>
  <li><a href="./Compress::Bzip2.html#AUTHOR1">AUTHOR</a></li>
  <li><a href="./Compress::Bzip2.html#MODIFICATION-HISTORY">MODIFICATION HISTORY</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Compress::Bzip2 - Interface to Bzip2 compression library</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>    use Compress::Bzip2 qw(:all :constant :utilities :gzip);

    ($bz, $status) = bzdeflateInit( [PARAMS] );
    ($out, $status) = $bz-&gt;bzdeflate($buffer) ; # compress

    ($bz, $status) = bzinflateInit( [PARAMS] );
    ($out, $status) = $bz-&gt;bzinflate($buffer);  # uncompress

    ($out, $status) = $bz-&gt;bzflush() ;
    ($out, $status) = $bz-&gt;bzclose() ;

    $dest = memBzip($source);
        alias compress
    $dest = memBunzip($source);
        alias decompress

    $bz = Compress::Bzip2-&gt;new( [PARAMS] );

    $bz = bzopen($filename or filehandle, $mode);
        alternate, with $bz created by new():
    $bz-&gt;bzopen($filename or filehandle, $mode);

    $bytesread = $bz-&gt;bzread($buffer [,$size]) ;
    $bytesread = $bz-&gt;bzreadline($line);
    $byteswritten = $bz-&gt;bzwrite($buffer [,$limit]);
    $errstring = $bz-&gt;bzerror();
    $status = $bz-&gt;bzeof();
    $status = $bz-&gt;bzflush();
    $status = $bz-&gt;bzclose() ;

    $status = $bz-&gt;bzsetparams( $param =&gt; $setting );

    $bz-&gt;total_in() ;
    $bz-&gt;total_out() ;

    $verstring = $bz-&gt;bzversion();

    $Compress::Bzip2::bzerrno</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>The <i>Compress::Bzip2</i> module provides a Perl interface to the <b>bzip2</b> compression library (see <a href="./Compress::Bzip2.html#AUTHOR">&quot;AUTHOR&quot;</a> for details about where to get <i>Bzip2</i>). A relevant subset of the functionality provided by <i>bzip2</i> is available in <i>Compress::Bzip2</i>.</p>

<p>All string parameters can either be a scalar or a scalar reference.</p>

<p>The module can be split into two general areas of functionality, namely in-memory compression/decompression and read/write access to <i>bzip2</i> files. Each of these areas will be discussed separately below.</p>

<p><b>NOTE</b></p>

<p><i>Compress::Bzip2</i> is just a simple <i>bzip2</i> binding, comparable to the old <a href="https://metacpan.org/pod/Compress::Zlib">Compress::Zlib</a> library. It is not well integrated into PerlIO, use the preferred <a href="https://metacpan.org/pod/IO::Compress::Bzip2">IO::Compress::Bzip2</a> instead.</p>

<h1 id="FILE-READ/WRITE-INTERFACE"><a id="FILE"></a><a id="FILE-READ-WRITE-INTERFACE"></a>FILE READ/WRITE INTERFACE</h1>

<p>A number of functions are supplied in <i>bzlib</i> for reading and writing <i>bzip2</i> files. Unfortunately, most of them are not suitable. So, this module provides another interface, built over top of the low level bzlib methods.</p>

<h2 id="$bz-=-bzopen(filename-or-filehandle,-mode)"><a id="bz---bzopen-filename-or-filehandle--mode"></a><b>$bz = bzopen(filename or filehandle, mode)</b></h2>

<p>This function returns an object which is used to access the other <i>bzip2</i> methods.</p>

<p>The <b>mode</b> parameter is used to specify both whether the file is opened for reading or writing, with &quot;r&quot; or &quot;w&quot; respectively.</p>

<p>If a reference to an open filehandle is passed in place of the filename, it better be positioned to the start of a compression/decompression sequence.</p>

<p>WARNING: With Perl 5.6 you cannot use a filehandle because of SEGV in destruction with bzclose or an implicit close.</p>

<h2 id="$bz-=-Compress::Bzip2-&gt;new(-[PARAMS]-)"><a id="bz---Compress::Bzip2--new---PARAMS"></a><b>$bz = Compress::Bzip2-&gt;new( [PARAMS] )</b></h2>

<p>Create a Compress::Bzip2 object. Optionally, provide compression/decompression parameters as a keyword =&gt; setting list. See <i>bzsetparams()</i> for a description of the parameters.</p>

<h2 id="$bz-&gt;bzopen(filename-or-filehandle,-mode)"><a id="bz--bzopen-filename-or-filehandle--mode"></a><b>$bz-&gt;bzopen(filename or filehandle, mode)</b></h2>

<p>This is bzopen, but it uses an object previously created by the new method. Other than that, it is identical to the above bzopen.</p>

<h2 id="$bytesread-=-$bz-&gt;bzread($buffer-[,-$size])-;"><a id="bytesread----bz--bzread-buffer----size"></a><b>$bytesread = $bz-&gt;bzread($buffer [, $size]) ;</b></h2>

<p>Reads <b>$size</b> bytes from the compressed file into <b>$buffer</b>. If <b>$size</b> is not specified, it will default to 4096. If the scalar <b>$buffer</b> is not large enough, it will be extended automatically.</p>

<p>Returns the number of bytes actually read. On EOF it returns 0 and in the case of an error, -1.</p>

<h2 id="$bytesread-=-$bz-&gt;bzreadline($line)-;"><a id="bytesread----bz--bzreadline-line"></a><b>$bytesread = $bz-&gt;bzreadline($line) ;</b></h2>

<p>Reads the next line from the compressed file into <b>$line</b>.</p>

<p>Returns the number of bytes actually read. On EOF it returns 0 and in the case of an error, -1.</p>

<p>It IS legal to intermix calls to <b>bzread</b> and <b>bzreadline</b>.</p>

<p>At this time <b>bzreadline</b> ignores the variable <code>$/</code> (<code>$INPUT_RECORD_SEPARATOR</code> or <code>$RS</code> when <code>English</code> is in use). The end of a line is denoted by the C character <code>&#39;\n&#39;</code>.</p>

<h2 id="$byteswritten-=-$bz-&gt;bzwrite($buffer-[,-$limit])-;"><a id="byteswritten----bz--bzwrite-buffer----limit"></a><b>$byteswritten = $bz-&gt;bzwrite($buffer [, $limit]) ;</b></h2>

<p>Writes the contents of <b>$buffer</b> to the compressed file. Returns the number of bytes actually written, or 0 on error.</p>

<p>If $limit is given and non-zero, then only that many bytes from $buffer will be written.</p>

<h2 id="$status-=-$bz-&gt;bzflush($flush)-;"><a id="status----bz--bzflush-flush"></a><b>$status = $bz-&gt;bzflush($flush) ;</b></h2>

<p>Flushes all pending output to the compressed file. Works identically to the <i>zlib</i> function it interfaces to. Note that the use of <b>bzflush</b> can degrade compression.</p>

<p>Returns <code>BZ_OK</code> if <b>$flush</b> is <code>BZ_FINISH</code> and all output could be flushed. Otherwise the bzlib error code is returned.</p>

<p>Refer to the <i>bzlib</i> documentation for the valid values of <b>$flush</b>.</p>

<h2 id="$status-=-$bz-&gt;bzeof()-;"><a id="status----bz--bzeof"></a><b>$status = $bz-&gt;bzeof() ;</b></h2>

<p>Returns 1 if the end of file has been detected while reading the input file, otherwise returns 0.</p>

<h2 id="$bz-&gt;bzclose"><a id="bz--bzclose"></a><b>$bz-&gt;bzclose</b></h2>

<p>Closes the compressed file. Any pending data is flushed to the file before it is closed.</p>

<h2 id="$bz-&gt;bzsetparams(-[PARAMS]-);"><a id="bz--bzsetparams---PARAMS"></a><b>$bz-&gt;bzsetparams( [PARAMS] );</b></h2>

<p>Change settings for the deflate stream <code>$bz</code>.</p>

<p>The list of the valid options is shown below. Options not specified will remain unchanged.</p>

<dl>

<dt id="-verbosity"><a id="verbosity"></a><b>-verbosity</b></dt>
<dd>

<p>Defines the verbosity level. Valid values are 0 through 4,</p>

<p>The default is <code>-verbosity =&gt; 0</code>.</p>

</dd>
<dt id="-blockSize100k"><a id="blockSize100k"></a><b>-blockSize100k</b></dt>
<dd>

<p>For bzip object opened for stream deflation or write.</p>

<p>Defines the buffering factor of compression method. The algorithm buffers all data until the buffer is full, then it flushes all the data out. Use -blockSize100k to specify the size of the buffer.</p>

<p>Valid settings are 1 through 9, representing a blocking in multiples of 100k.</p>

<p>Note that each such block has an overhead of leading and trailing synchronization bytes. bzip2 recovery uses this information to pull useable data out of a corrupted file.</p>

<p>A streaming application would probably want to set the blocking low.</p>

</dd>
<dt id="-workFactor"><a id="workFactor"></a><b>-workFactor</b></dt>
<dd>

<p>For bzip object opened for stream deflation or write.</p>

<p>The workFactor setting tells the deflation algorithm how much work to invest to compensate for repetitive data.</p>

<p>workFactor may be a number from 0 to 250 inclusive. The default setting is 30.</p>

<p>See the bzip documentation for more information.</p>

</dd>
<dt id="-small"><a id="small"></a><b>-small</b></dt>
<dd>

<p>For bzip object opened for stream inflation or read.</p>

<p><b>small</b> may be 0 or 1. Set <code>small</code> to one to use a slower, less memory intensive algorithm.</p>

</dd>
</dl>

<h2 id="$bz-&gt;bzerror"><a id="bz--bzerror"></a><b>$bz-&gt;bzerror</b></h2>

<p>Returns the <i>bzlib</i> error message or number for the last operation associated with <b>$bz</b>. The return value will be the <i>bzlib</i> error number when used in a numeric context and the <i>bzlib</i> error message when used in a string context. The <i>bzlib</i> error number constants, shown below, are available for use.</p>

<pre><code>  BZ_CONFIG_ERROR
  BZ_DATA_ERROR
  BZ_DATA_ERROR_MAGIC
  BZ_FINISH
  BZ_FINISH_OK
  BZ_FLUSH
  BZ_FLUSH_OK
  BZ_IO_ERROR
  BZ_MAX_UNUSED
  BZ_MEM_ERROR
  BZ_OK
  BZ_OUTBUFF_FULL
  BZ_PARAM_ERROR
  BZ_RUN
  BZ_RUN_OK
  BZ_SEQUENCE_ERROR
  BZ_STREAM_END
  BZ_UNEXPECTED_EOF</code></pre>

<h2 id="$bz-&gt;bzclearerr"><a id="bz--bzclearerr"></a><b>$bz-&gt;bzclearerr</b></h2>

<h2 id="$bzerrno"><a id="bzerrno"></a><b>$bzerrno</b></h2>

<p>The <b>$bzerrno</b> scalar holds the error code associated with the most recent <i>bzip2</i> routine. Note that unlike <b>bzerror()</b>, the error is <i>not</i> associated with a particular file.</p>

<p>As with <b>bzerror()</b> it returns an error number in numeric context and an error message in string context. Unlike <b>bzerror()</b> though, the error message will correspond to the <i>bzlib</i> message when the error is associated with <i>bzlib</i> itself, or the UNIX error message when it is not (i.e. <i>bzlib</i> returned <code>Z_ERRORNO</code>).</p>

<p>As there is an overlap between the error numbers used by <i>bzlib</i> and UNIX, <b>$bzerrno</b> should only be used to check for the presence of <i>an</i> error in numeric context. Use <b>bzerror()</b> to check for specific <i>bzlib</i> errors. The <i>bzcat</i> example below shows how the variable can be used safely.</p>

<h2 id="$bz-&gt;prefix"><a id="bz--prefix"></a><b>$bz-&gt;prefix</b></h2>

<p>Returns the additional 5 byte header which is prepended to the bzip2 header starting with <code>BZh</code> when using memBzip/compress.</p>

<h1 id="Compress::Bzip2-Utilities"><a id="Compress"></a>Compress::Bzip2 Utilities</h1>

<p>Options: -d -c -z -f -v -k -s -1..9</p>

<h2 id="bzip2(-[OPTS],-filename)"><a id="bzip2"></a><a id="bzip2---OPTS--filename"></a>bzip2( [OPTS], filename)</h2>

<h2 id="bunzip2(filename)"><a id="bunzip2"></a><a id="bunzip2-filename"></a>bunzip2(filename)</h2>

<h2 id="bzcat(filenames...)"><a id="bzcat"></a><a id="bzcat-filenames"></a>bzcat(filenames...)</h2>

<h2 id="bzlibversion()"><a id="bzlibversion"></a>bzlibversion()</h2>

<h2 id="bzinflateInit(-opts...-)"><a id="bzinflateInit"></a><a id="bzinflateInit--opts"></a>bzinflateInit( opts... )</h2>

<h1 id="Internal-Utilties"><a id="Internal"></a>Internal Utilties</h1>

<h2 id="bz_seterror(errno,-msg)-=head2-$bz-&gt;is_read()-=head2-$bz-&gt;is_stream()-=head2-$bz-&gt;is_write()-=head2-$bz-&gt;total_in()-=head2-$bz-&gt;total_out()-=head2-version()"><a id="bz_seterror"></a><a id="bz_seterror-errno--msg---head2--bz--is_read---head2--bz--is_stream---head2--bz--is_write---head2--bz--total_in---head2--bz--total_out---head2-version"></a>bz_seterror(errno, msg) =head2 $bz-&gt;is_read() =head2 $bz-&gt;is_stream() =head2 $bz-&gt;is_write() =head2 $bz-&gt;total_in() =head2 $bz-&gt;total_out() =head2 version()</h2>

<h1 id="Compress::Bzip2-1.03-COMPATIBILITY"><a id="Compress1"></a>Compress::Bzip2 1.03 COMPATIBILITY</h1>

<p>While the 2.x thread forked off of 1.00, another line of development came to a head at 1.03. The 1.03 version worked with bzlib 1.0.2, had improvements to the error handling, single buffer inflate/deflate, a streaming interface to inflate/deflate, and a cpan style test suite.</p>

<h2 id="$dest-=-compress(-$string,-[$level]-)"><a id="dest---compress---string---level"></a><b>$dest = compress( $string, [$level] )</b></h2>

<p>Alias to <a href="https://metacpan.org/pod/memBzip">memBzip</a>, this compresses string, using the optional compression level, 1 through 9, the default being 6. Returns a string containing the compressed data.</p>

<p>On error <i>undef</i> is returned.</p>

<h2 id="$dest-=-decompress($string,-[$level])"><a id="dest---decompress-string---level"></a><b>$dest = decompress($string, [$level])</b></h2>

<p>Alias to <a href="https://metacpan.org/pod/memBunzip">memBunzip</a>, this decompresses the data in string, returning a string containing the decompressed data.</p>

<p>On error <i>undef</i> is returned.</p>

<h2 id="uncompress($string,-[$level])"><a id="uncompress"></a><a id="uncompress-string---level"></a>uncompress($string, [$level])</h2>

<p>Another alias to <a href="https://metacpan.org/pod/memBunzip">memBunzip</a></p>

<h2 id="$stream-=-compress_init(-[PARAMS]-)"><a id="stream---compress_init---PARAMS"></a><b>$stream = compress_init( [PARAMS] )</b></h2>

<p>Alias to bzdeflateInit. In addition to the named parameters documented for bzdeflateInit, the following are accepted:</p>

<pre><code>   -level, alias to -blockSize100k
   -buffer, to set the buffer size.</code></pre>

<p>The -buffer option is ignored. The intermediate buffer size is not changeable.</p>

<h2 id="$stream-=-decompress_init(-[PARAMS]-)"><a id="stream---decompress_init---PARAMS"></a><b>$stream = decompress_init( [PARAMS] )</b></h2>

<p>Alias to bzinflateInit. See bzinflateInit for a description of the parameters. The option &quot;-buffer&quot; is accepted, but ignored.</p>

<h2 id="$output-=-$stream-&gt;add(-$string-)"><a id="output----stream--add---string"></a><b>$output = $stream-&gt;add( $string )</b></h2>

<p>Add data to be compressed/decompressed. Returns whatever output is available (possibly none, if it&#39;s still buffering it), or undef on error.</p>

<h2 id="$output-=-$stream-&gt;finish(-[$string]-)"><a id="output----stream--finish---string"></a><b>$output = $stream-&gt;finish( [$string] )</b></h2>

<p>Finish the operation; takes an optional final data string. Whatever is returned completes the output; returns undef on error.</p>

<h2 id="$stream-&gt;error"><a id="stream--error"></a><b>$stream-&gt;error</b></h2>

<p>Like the function, but applies to the current object only. Note that errors in a stream object are also returned by the function.</p>

<h2 id="$stream-&gt;input_size"><a id="stream--input_size"></a><b>$stream-&gt;input_size</b></h2>

<p>Alias to total_in. Total bytes passed to the stream.</p>

<h2 id="$stream-&gt;output_size"><a id="stream--output_size"></a><b>$stream-&gt;output_size</b></h2>

<p>Alias to total_out. Total bytes received from the stream.</p>

<h1 id="GZIP-COMPATIBILITY-INTERFACE"><a id="GZIP"></a>GZIP COMPATIBILITY INTERFACE</h1>

<p>Except for the exact state and error numbers, this package presents an interface very much like that given by the Compress::Zlib package. Mostly, if you take the method name, state or error number from Compress::Zlib and replace the &quot;g&quot; with a &quot;b&quot;, your code should work.</p>

<p>To make the interoperability even easier, all the Compress::Zlib method names have been used as aliases or cover functions for the bzip2 methods.</p>

<p>Therefore, most code that uses Compress::Zlib should be able to use this package, with a one line change.</p>

<p>Simply change</p>

<pre><code>   $gz = Compress::Zlib::gzopen( &quot;filename&quot;, &quot;w&quot; );</code></pre>

<p>to</p>

<pre><code>   $gz = Compress::Bzip2::gzopen( &quot;filename&quot;, &quot;w&quot; );</code></pre>

<p>Some of the Compress::Zlib aliases don&#39;t return anything useful, like crc32 or adler32, cause bzip2 doesn&#39;t do that sort of thing.</p>

<h2 id="$gz-=-gzopen(-$filename,-$mode-)"><a id="gz---gzopen---filename---mode"></a><b> $gz = gzopen( $filename, $mode ) </b></h2>

<p>Alias for bzopen.</p>

<h2 id="$gz-&gt;gzread(-$buffer,-[-$length-]-)"><a id="gz--gzread---buffer-----length"></a><b> $gz-&gt;gzread( $buffer, [ $length ] ) </b></h2>

<p>Alias for bzread.</p>

<h2 id="$gz-&gt;gzreadline(-$buffer-)"><a id="gz--gzreadline---buffer"></a><b> $gz-&gt;gzreadline( $buffer ) </b></h2>

<p>Alias for bzreadline.</p>

<h2 id="$gz-&gt;gzwrite(-$buffer-)"><a id="gz--gzwrite---buffer"></a><b> $gz-&gt;gzwrite( $buffer ) </b></h2>

<p>Alias for bzwrite.</p>

<h2 id="$gz-&gt;gzflush(-[$flushtype]-)"><a id="gz--gzflush---flushtype"></a><b> $gz-&gt;gzflush( [$flushtype] ) </b></h2>

<p>Alias for bzflush, with return code translation.</p>

<h2 id="$gz-&gt;gzclose(-)"><a id="gz--gzclose"></a><b> $gz-&gt;gzclose( ) </b></h2>

<p>Alias for bzclose.</p>

<h2 id="$gz-&gt;gzeof(-)"><a id="gz--gzeof"></a><b> $gz-&gt;gzeof( ) </b></h2>

<p>Alias for bzeof.</p>

<h2 id="$gz-&gt;gzerror(-)"><a id="gz--gzerror"></a><b> $gz-&gt;gzerror( ) </b></h2>

<p>Alias for bzerror.</p>

<h2 id="$gz-&gt;gzsetparams(-$level,-$strategy-)"><a id="gz--gzsetparams---level---strategy"></a><b> $gz-&gt;gzsetparams( $level, $strategy ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-=-deflateInit(-[OPTS]-)"><a id="d---deflateInit---OPTS"></a><b> $d = deflateInit( [OPTS] ) </b></h2>

<p>Alias for bzdeflateInit, with return code translation.</p>

<p>All OPTS are ignored.</p>

<h2 id="$d-&gt;deflate(-$buffer-)"><a id="d--deflate---buffer"></a><b> $d-&gt;deflate( $buffer ) </b></h2>

<p>Alias for bzdeflate, with return code translation.</p>

<h2 id="$d-&gt;deflateParams(-[OPTS]-)"><a id="d--deflateParams---OPTS"></a><b> $d-&gt;deflateParams( [OPTS] ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-&gt;flush(-[$flushtype]-)"><a id="d--flush---flushtype"></a><b> $d-&gt;flush( [$flushtype] ) </b></h2>

<p>Cover function for bzflush or bzclose, depending on $flushtype.</p>

<p>See the Compress::Zlib documentation for more information.</p>

<h2 id="$d-&gt;dict_adler(-)"><a id="d--dict_adler"></a><b> $d-&gt;dict_adler( ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-&gt;msg(-)"><a id="d--msg"></a><b> $d-&gt;msg( ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-=-inflateInit(-[OPTS]-)"><a id="d---inflateInit---OPTS"></a><b> $d = inflateInit( [OPTS] ) </b></h2>

<p>Alias for bzinflateInit, with return code translation.</p>

<p>All OPTS are ignored.</p>

<h2 id="$d-&gt;inflate(-)"><a id="d--inflate"></a><b> $d-&gt;inflate( ) </b></h2>

<p>Alias for bzinflate, with return code translation.</p>

<h2 id="$d-&gt;inflateSync(-)"><a id="d--inflateSync"></a><b> $d-&gt;inflateSync( ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-&gt;adler32(-$crc-)"><a id="d--adler32---crc"></a><b> $d-&gt;adler32( $crc ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$d-&gt;crc32(-$crc-)"><a id="d--crc32---crc"></a><b> $d-&gt;crc32( $crc ) </b></h2>

<p>This is a no-op.</p>

<h2 id="$buffer-=-memGzip(-$buffer-)"><a id="buffer---memGzip---buffer"></a><b> $buffer = memGzip( $buffer ) </b></h2>

<p>Alias for memBzip.</p>

<h2 id="$buffer-=-memGunzip(-$buffer-)"><a id="buffer---memGunzip---buffer"></a><b> $buffer = memGunzip( $buffer ) </b></h2>

<p>Alias for memBunzip.</p>

<h1 id="IN-MEMORY-COMPRESS/UNCOMPRESS"><a id="IN"></a><a id="IN-MEMORY-COMPRESS-UNCOMPRESS"></a>IN-MEMORY COMPRESS/UNCOMPRESS</h1>

<p>Two high-level functions are provided by <i>bzlib</i> to perform in-memory compression. They are <b>memBzip</b> and <b>memBunzip</b>. Two Perl subs are provided which provide similar functionality.</p>

<h2 id="$compressed-=-memBzip($buffer);"><a id="compressed---memBzip-buffer"></a><b>$compressed = memBzip($buffer);</b></h2>

<p>Compresses <b>$buffer</b>. If successful it returns the compressed data. Otherwise it returns <i>undef</i>.</p>

<p>The buffer parameter can either be a scalar or a scalar reference.</p>

<p>Essentially, an in-memory bzip file is created. It creates a minimal bzip header, which adds 5 bytes before the bzip2 specific BZh header.</p>

<h2 id="$uncompressed-=-memBunzip($buffer);"><a id="uncompressed---memBunzip-buffer"></a><b>$uncompressed = memBunzip($buffer);</b></h2>

<p>Uncompresses <b>$buffer</b>. If successful it returns the uncompressed data. Otherwise it returns <i>undef</i>.</p>

<p>The source buffer can either be a scalar or a scalar reference.</p>

<p>The buffer parameter can either be a scalar or a scalar reference. The contents of the buffer parameter are destroyed after calling this function.</p>

<h1 id="STREAM-DEFLATE-(=-COMPRESS)"><a id="STREAM"></a><a id="STREAM-DEFLATE---COMPRESS"></a>STREAM DEFLATE (= COMPRESS)</h1>

<p>The Perl interface will <i>always</i> consume the complete input buffer before returning. Also the output buffer returned will be automatically grown to fit the amount of output available.</p>

<p>Here is a definition of the interface available:</p>

<h2 id="($d,-$status)-=-bzdeflateInit(-[PARAMS]-)"><a id="d---status----bzdeflateInit---PARAMS"></a><b>($d, $status) = bzdeflateInit( [PARAMS] )</b></h2>

<p>Initialises a deflation stream.</p>

<p>If successful, it will return the initialised deflation stream, <b>$d</b> and <b>$status</b> of <code>BZ_OK</code> in a list context. In scalar context it returns the deflation stream, <b>$d</b>, only.</p>

<p>If not successful, the returned deflation stream (<b>$d</b>) will be <i>undef</i> and <b>$status</b> will hold the exact <i>bzip2</i> error code.</p>

<p>The function optionally takes a number of named options specified as <code>-Name=&gt;value</code> pairs. This allows individual options to be tailored without having to specify them all in the parameter list.</p>

<p>Here is a list of the valid options:</p>

<dl>

<dt id="-verbosity1"><a id="verbosity1"></a><b>-verbosity</b></dt>
<dd>

<p>Defines the verbosity level. Valid values are 0 through 4,</p>

<p>The default is <code>-verbosity =&gt; 0</code>.</p>

</dd>
<dt id="-blockSize100k1"><a id="blockSize100k1"></a><b>-blockSize100k</b></dt>
<dd>

<p>Defines the buffering factor of compression method. The algorithm buffers all data until the buffer is full, then it flushes all the data out. Use -blockSize100k to specify the size of the buffer.</p>

<p>Valid settings are 1 through 9, representing a blocking in multiples of 100k.</p>

<p>Note that each such block has an overhead of leading and trailing synchronization bytes. bzip2 recovery uses this information to pull useable data out of a corrupted file.</p>

<p>A streaming application would probably want to set the blocking low.</p>

</dd>
<dt id="-workFactor1"><a id="workFactor1"></a><b>-workFactor</b></dt>
<dd>

<p>The workFactor setting tells the deflation algorithm how much work to invest to compensate for repetitive data.</p>

<p>workFactor may be a number from 0 to 250 inclusive. The default setting is 30.</p>

<p>See the bzip documentation for more information.</p>

</dd>
</dl>

<p>Here is an example of using the <b>deflateInit</b> optional parameter list to override the default buffer size and compression level. All other options will take their default values.</p>

<pre><code>    bzdeflateInit( -blockSize100k =&gt; 1, -verbosity =&gt; 1 );</code></pre>

<h2 id="($out,-$status)-=-$d-&gt;bzdeflate($buffer)"><a id="out---status-----d--bzdeflate-buffer"></a><b>($out, $status) = $d-&gt;bzdeflate($buffer)</b></h2>

<p>Deflates the contents of <b>$buffer</b>. The buffer can either be a scalar or a scalar reference. When finished, <b>$buffer</b> will be completely processed (assuming there were no errors). If the deflation was successful it returns deflated output, <b>$out</b>, and a status value, <b>$status</b>, of <code>Z_OK</code>.</p>

<p>On error, <b>$out</b> will be <i>undef</i> and <b>$status</b> will contain the <i>zlib</i> error code.</p>

<p>In a scalar context <b>bzdeflate</b> will return <b>$out</b> only.</p>

<p>As with the internal buffering of the <i>deflate</i> function in <i>bzip2</i>, it is not necessarily the case that any output will be produced by this method. So don&#39;t rely on the fact that <b>$out</b> is empty for an error test. In fact, given the size of bzdeflates internal buffer, with most files it&#39;s likely you won&#39;t see any output at all until flush or close.</p>

<h2 id="($out,-$status)-=-$d-&gt;bzflush([flush_type])"><a id="out---status-----d--bzflush-flush_type"></a><b>($out, $status) = $d-&gt;bzflush([flush_type])</b></h2>

<p>Typically used to finish the deflation. Any pending output will be returned via <b>$out</b>. <b>$status</b> will have a value <code>BZ_OK</code> if successful.</p>

<p>In a scalar context <b>bzflush</b> will return <b>$out</b> only.</p>

<p>Note that flushing can seriously degrade the compression ratio, so it should only be used to terminate a decompression (using <code>BZ_FLUSH</code>) or when you want to create a <i>full flush point</i> (using <code>BZ_FINISH</code>).</p>

<p>The allowable values for <code>flush_type</code> are <code>BZ_FLUSH</code> and <code>BZ_FINISH</code>.</p>

<p>For a handle opened for &quot;w&quot; (bzwrite), the default is <code>BZ_FLUSH</code>. For a stream, the default for <code>flush_type</code> is <code>BZ_FINISH</code> (which is essentially a close and reopen).</p>

<p>It is strongly recommended that you only set the <code>flush_type</code> parameter if you fully understand the implications of what it does. See the <code>bzip2</code> documentation for details.</p>

<h2 id="Example">Example</h2>

<p>Here is a trivial example of using <b>bzdeflate</b>. It simply reads standard input, deflates it and writes it to standard output.</p>

<pre><code>    use strict ;
    use warnings ;

    use Compress::Bzip2 ;

    binmode STDIN;
    binmode STDOUT;
    my $x = bzdeflateInit()
       or die &quot;Cannot create a deflation stream\n&quot; ;

    my ($output, $status) ;
    while (&lt;&gt;)
    {
        ($output, $status) = $x-&gt;bzdeflate($_) ;

        $status == BZ_OK
            or die &quot;deflation failed\n&quot; ;

        print $output ;
    }

    ($output, $status) = $x-&gt;bzclose() ;

    $status == BZ_OK
        or die &quot;deflation failed\n&quot; ;

    print $output ;</code></pre>

<h1 id="STREAM-INFLATE"><a id="STREAM1"></a>STREAM INFLATE</h1>

<p>Here is a definition of the interface:</p>

<h2 id="($i,-$status)-=-inflateInit()"><a id="i---status----inflateInit"></a><b>($i, $status) = inflateInit()</b></h2>

<p>Initialises an inflation stream.</p>

<p>In a list context it returns the inflation stream, <b>$i</b>, and the <i>zlib</i> status code (<b>$status</b>). In a scalar context it returns the inflation stream only.</p>

<p>If successful, <b>$i</b> will hold the inflation stream and <b>$status</b> will be <code>BZ_OK</code>.</p>

<p>If not successful, <b>$i</b> will be <i>undef</i> and <b>$status</b> will hold the <i>bzlib.h</i> error code.</p>

<p>The function optionally takes a number of named options specified as <code>-Name=&gt;value</code> pairs. This allows individual options to be tailored without having to specify them all in the parameter list.</p>

<p>For backward compatibility, it is also possible to pass the parameters as a reference to a hash containing the name=&gt;value pairs.</p>

<p>The function takes one optional parameter, a reference to a hash. The contents of the hash allow the deflation interface to be tailored.</p>

<p>Here is a list of the valid options:</p>

<dl>

<dt id="-small1"><a id="small1"></a><b>-small</b></dt>
<dd>

<p><b>small</b> may be 0 or 1. Set <code>small</code> to one to use a slower, less memory intensive algorithm.</p>

</dd>
<dt id="-verbosity2"><a id="verbosity2"></a><b>-verbosity</b></dt>
<dd>

<p>Defines the verbosity level. Valid values are 0 through 4,</p>

<p>The default is <code>-verbosity =&gt; 0</code>.</p>

</dd>
</dl>

<p>Here is an example of using the <b>bzinflateInit</b> optional parameter.</p>

<pre><code>    bzinflateInit( -small =&gt; 1, -verbosity =&gt; 1 );</code></pre>

<h2 id="($out,-$status)-=-$i-&gt;bzinflate($buffer)"><a id="out---status-----i--bzinflate-buffer"></a><b>($out, $status) = $i-&gt;bzinflate($buffer)</b></h2>

<p>Inflates the complete contents of <b>$buffer</b>. The buffer can either be a scalar or a scalar reference.</p>

<p>Returns <code>BZ_OK</code> if successful and <code>BZ_STREAM_END</code> if the end of the compressed data has been successfully reached. If not successful, <b>$out</b> will be <i>undef</i> and <b>$status</b> will hold the <i>bzlib</i> error code.</p>

<p>The <code>$buffer</code> parameter is modified by <code>bzinflate</code>. On completion it will contain what remains of the input buffer after inflation. This means that <code>$buffer</code> will be an empty string when the return status is <code>BZ_OK</code>. When the return status is <code>BZ_STREAM_END</code> the <code>$buffer</code> parameter will contains what (if anything) was stored in the input buffer after the deflated data stream.</p>

<p>This feature is useful when processing a file format that encapsulates a compressed data stream.</p>

<h2 id="Example1">Example</h2>

<p>Here is an example of using <b>bzinflate</b>.</p>

<pre><code>    use strict ;
    use warnings ;

    use Compress::Bzip2;

    my $x = bzinflateInit()
       or die &quot;Cannot create a inflation stream\n&quot; ;

    my $input = &#39;&#39; ;
    binmode STDIN;
    binmode STDOUT;

    my ($output, $status) ;
    while (read(STDIN, $input, 4096))
    {
        ($output, $status) = $x-&gt;bzinflate(\$input) ;

        print $output
            if $status == BZ_OK or $status == BZ_STREAM_END ;

        last if $status != BZ_OK ;
    }

    die &quot;inflation failed\n&quot;
        unless $status == BZ_STREAM_END ;</code></pre>

<h1 id="EXAMPLES">EXAMPLES</h1>

<p>Here are some example scripts of using the interface.</p>

<h2 id="A-bzcat-function"><a id="A"></a><b>A bzcat function</b></h2>

<pre><code>  use strict ;
  use warnings ;

  use Compress::Bzip2 ;

  die &quot;Usage: bzcat file...\n&quot; unless @ARGV ;

  my $file ;

  foreach $file (@ARGV) {
    my $buffer ;

    my $bz = bzopen($file, &quot;rb&quot;)
       or die &quot;Cannot open $file: $bzerrno\n&quot; ;

    print $buffer while $bz-&gt;bzread($buffer) &gt; 0 ;

    die &quot;Error reading from $file: $bzerrno&quot; . ($bzerrno+0) . &quot;\n&quot;
       if $bzerrno != BZ_STREAM_END ;

    $bz-&gt;bzclose() ;
  }</code></pre>

<h2 id="A-grep-using-bzreadline"><a id="A1"></a><b>A grep using bzreadline</b></h2>

<pre><code>  use strict ;
  use warnings ;

  use Compress::Bzip2 ;

  die &quot;Usage: bzgrep pattern file...\n&quot; unless @ARGV &gt;= 2;

  my $pattern = shift ;

  my $file ;

  foreach $file (@ARGV) {
    my $bz = bzopen($file, &quot;rb&quot;)
       or die &quot;Cannot open $file: $bzerrno\n&quot; ;

    while ($bz-&gt;bzreadline($_) &gt; 0) {
      print if /$pattern/ ;
    }

    die &quot;Error reading from $file: $bzerrno\n&quot;
      if $bzerrno != Z_STREAM_END ;

    $bz-&gt;bzclose() ;
  }</code></pre>

<h2 id="Streaming-Compression"><a id="Streaming"></a><b>Streaming Compression</b></h2>

<p>This script, <i>bzstream</i>, does the opposite of the <i>bzcat</i> script above. It reads from standard input and writes a bzip file to standard output.</p>

<pre><code>  use strict ;
  use warnings ;

  use Compress::Bzip2 ;

  binmode STDOUT;       # bzopen only sets it on the fd

  my $bz = bzopen(\*STDOUT, &quot;wb&quot;)
     or die &quot;Cannot open stdout: $bzerrno\n&quot; ;

  while (&lt;&gt;) {
    $bz-&gt;bzwrite($_) or die &quot;error writing: $bzerrno\n&quot; ;
  }

  $bz-&gt;bzclose ;</code></pre>

<h1 id="EXPORT">EXPORT</h1>

<p>Use the tags :all, :utilities, :constants, :bzip1 and :gzip.</p>

<h2 id="Export-tag-:all"><a id="Export"></a>Export tag :all</h2>

<p>This exports all the exportable methods.</p>

<h2 id="Export-tag-:constants"><a id="Export1"></a>Export tag :constants</h2>

<p>This exports only the BZ_* constants.</p>

<h2 id="Export-tag-:bzip1"><a id="Export2"></a>Export tag :bzip1</h2>

<p>This exports the Compress::Bzip2 1.x functions, for compatibility.</p>

<pre><code>   compress
   decompress
   compress_init
   decompress_init
   version</code></pre>

<p>These are actually aliases to memBzip and memBunzip.</p>

<h2 id="Export-tag-:utilities"><a id="Export3"></a>Export tag :utilities</h2>

<p>This gives an interface to the bzip2 methods.</p>

<pre><code>    bzopen
    bzinflateInit
    bzdeflateInit
    memBzip
    memBunzip
    bzip2
    bunzip2
    bzcat
    bzlibversion
    $bzerrno</code></pre>

<h2 id="Export-tag-:gzip"><a id="Export4"></a>Export tag :gzip</h2>

<p>This gives compatibility with Compress::Zlib.</p>

<pre><code>    gzopen
    gzinflateInit
    gzdeflateInit
    memGzip
    memGunzip
    $gzerrno</code></pre>

<h1 id="Exportable-constants"><a id="Exportable"></a>Exportable constants</h1>

<p>All the <i>bzlib</i> constants are automatically imported when you make use of <i>Compress::Bzip2</i>.</p>

<pre><code>  BZ_CONFIG_ERROR
  BZ_DATA_ERROR
  BZ_DATA_ERROR_MAGIC
  BZ_FINISH
  BZ_FINISH_OK
  BZ_FLUSH
  BZ_FLUSH_OK
  BZ_IO_ERROR
  BZ_MAX_UNUSED
  BZ_MEM_ERROR
  BZ_OK
  BZ_OUTBUFF_FULL
  BZ_PARAM_ERROR
  BZ_RUN
  BZ_RUN_OK
  BZ_SEQUENCE_ERROR
  BZ_STREAM_END
  BZ_UNEXPECTED_EOF</code></pre>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p>The documentation for zlib, bzip2 and Compress::Zlib.</p>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Rob Janes, &lt;arjay at cpan.org&gt;</p>

<h1 id="COPYRIGHT-AND-LICENSE"><a id="COPYRIGHT"></a>COPYRIGHT AND LICENSE</h1>

<p>Copyright (C) 2005 by Rob Janes</p>

<p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.</p>

<h1 id="AUTHOR1">AUTHOR</h1>

<p>The <i>Compress::Bzip2</i> module was originally written by Gawdi Azem <i>azemgi@rupert.informatik.uni-stuttgart.de</i>.</p>

<p>The first <i>Compress::Bzip2</i> module was written by Gawdi Azem <i>azemgi@rupert.informatik.uni-stuttgart.de</i>. It provided an interface to the in memory inflate and deflate routines.</p>

<p><i>Compress::Bzip2</i> was subsequently passed on to Marco Carnut <i>kiko@tempest.com.br</i> who shepherded it through to version 1.03, a set of changes which included upgrades to handle bzlib 1.0.2, and improvements to the in memory inflate and deflate routines. The streaming interface and error information were added by David Robins <i>dbrobins@davidrobins.net</i>.</p>

<p>Version 2 of <i>Compress::Bzip2</i> is due to Rob Janes, of arjay@cpan.org. This release is intended to give an interface close to that of Compress::Zlib. It&#39;s development forks from 1.00, not 1.03, so the streaming interface is not the same as that in 1.03, although apparently compatible as it passes the 1.03 test suite.</p>

<p>Minor subsequent fixes and releases were done by Reini Urban, rurban@cpan.org.</p>

<h1 id="MODIFICATION-HISTORY"><a id="MODIFICATION"></a>MODIFICATION HISTORY</h1>

<p>See the Changes file.</p>

<p>2.00 Second public release of <i>Compress::Bzip2</i>.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Compress::Bzip2, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Compress::Bzip2</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Compress::Bzip2</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Compress::Bzip2.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
